<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Robocup-denayer-project-a: read-only/trunk/source/infrarood.cpp Bron Bestand</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Gegenereerd door Doxygen 1.7.1 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Zoeken');
--></script>
<script type="text/javascript">
function hasClass(ele,cls) {
  return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}

function addClass(ele,cls) {
  if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}

function removeClass(ele,cls) {
  if (hasClass(ele,cls)) {
    var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
    ele.className=ele.className.replace(reg,' ');
  }
}

function toggleVisibility(linkObj) {
 var base = linkObj.getAttribute('id');
 var summary = document.getElementById(base + '-summary');
 var content = document.getElementById(base + '-content');
 var trigger = document.getElementById(base + '-trigger');
 if ( hasClass(linkObj,'closed') ) {
   summary.style.display = 'none';
   content.style.display = 'block';
   trigger.src = 'open.png';
   removeClass(linkObj,'closed');
   addClass(linkObj,'opened');
 } else if ( hasClass(linkObj,'opened') ) {
   summary.style.display = 'block';
   content.style.display = 'none';
   trigger.src = 'closed.png';
   removeClass(linkObj,'opened');
   addClass(linkObj,'closed');
 }
 return false;
}
</script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Hoofd&nbsp;Pagina</span></a></li>
      <li><a href="annotated.html"><span>Klassen</span></a></li>
      <li class="current"><a href="files.html"><span>Bestanden</span></a></li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
          <span class="left">
            <form id="FSearchBox" action="search.php" method="get">
              <img id="MSearchSelect" src="search/mag.png" alt=""/>
              <input type="text" id="MSearchField" name="query" value="Zoeken" size="20" accesskey="S" 
                     onfocus="searchBox.OnSearchFieldFocus(true)" 
                     onblur="searchBox.OnSearchFieldFocus(false)"/>
            </form>
          </span><span class="right"></span>
        </div>
      </li>
    </ul>
  </div>
  <div class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&nbsp;Lijst</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<h1>read-only/trunk/source/infrarood.cpp</h1>  </div>
</div>
<div class="contents">
<a href="infrarood_8cpp.html">Ga naar de documentatie van dit bestand.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment">Infrarood sensoren</span>
<a name="l00003"></a>00003 <span class="comment"></span>
<a name="l00004"></a>00004 <span class="comment">Bavo 19/03/11</span>
<a name="l00005"></a>00005 <span class="comment">*/</span>
<a name="l00006"></a>00006 
<a name="l00007"></a>00007 <span class="preprocessor">#include &quot;<a class="code" href="infrarood_8h.html">infrarood.h</a>&quot;</span>
<a name="l00008"></a>00008 
<a name="l00009"></a>00009 <span class="keyword">using namespace </span>std;
<a name="l00010"></a>00010 
<a name="l00011"></a><a class="code" href="class_i_r_sensors.html#af3da6ee28e82883dafac00c4961cf35e">00011</a> <span class="keywordtype">void</span> <a class="code" href="class_i_r_sensors.html#af3da6ee28e82883dafac00c4961cf35e" title="Thread::execute();.">IRSensors::execute</a>(<span class="keywordtype">void</span>)
<a name="l00012"></a>00012 {
<a name="l00013"></a>00013         <span class="keywordflow">while</span>(1)
<a name="l00014"></a>00014         {       
<a name="l00015"></a>00015                 cout &lt;&lt; <span class="stringliteral">&quot;running&quot;</span> &lt;&lt; endl;
<a name="l00016"></a>00016                 <a class="code" href="class_i_r_sensors.html#a71d43a2da760b6a636d6fc478f3c484c">main</a>();
<a name="l00017"></a>00017                 sleep(1);
<a name="l00018"></a>00018         }
<a name="l00019"></a>00019 }
<a name="l00020"></a>00020 
<a name="l00024"></a><a class="code" href="class_i_r_sensors.html#a6eaf3f22c0c02d1913d436918569322f">00024</a> <span class="keywordtype">int</span> <a class="code" href="class_i_r_sensors.html#a6eaf3f22c0c02d1913d436918569322f" title="haalt X balletje Geeft de X-coordinaat van het balletje relatief tov de linkersensor, 0 indien geen balletje te zien">IRSensors::getBx</a>(<span class="keywordtype">void</span>)
<a name="l00025"></a>00025 {
<a name="l00026"></a>00026         <span class="keywordflow">return</span> bx;
<a name="l00027"></a>00027 }
<a name="l00031"></a><a class="code" href="class_i_r_sensors.html#aeec6cc91957f7d667cc7472de47b0a61">00031</a> <span class="keywordtype">int</span> <a class="code" href="class_i_r_sensors.html#aeec6cc91957f7d667cc7472de47b0a61" title="haalt Y balletje Geeft de Y-coordinaat van het balletje relatief tov de linkersensor, 0 indien geen balletje te zien">IRSensors::getBy</a>(<span class="keywordtype">void</span>)
<a name="l00032"></a>00032 {
<a name="l00033"></a>00033         <span class="keywordflow">return</span> by;
<a name="l00034"></a>00034 }
<a name="l00038"></a><a class="code" href="class_i_r_sensors.html#a2efdf02bfc8ade8850328acce3c3646d">00038</a> <span class="keywordtype">bool</span> <a class="code" href="class_i_r_sensors.html#a2efdf02bfc8ade8850328acce3c3646d" title="haalt vlag balletje true als er een balletje in zicht is, false indien geen balletje te zien...">IRSensors::BFlag</a>(<span class="keywordtype">void</span>)
<a name="l00039"></a>00039 {
<a name="l00040"></a>00040         <span class="keywordflow">return</span> b;
<a name="l00041"></a>00041 }
<a name="l00042"></a>00042 
<a name="l00043"></a><a class="code" href="class_i_r_sensors.html#acb8969475a1a274360fd76cc1aa7ec9d">00043</a> <span class="keywordtype">int</span> <a class="code" href="class_i_r_sensors.html#acb8969475a1a274360fd76cc1aa7ec9d">IRSensors::getA1</a>(<span class="keywordtype">void</span>)
<a name="l00044"></a>00044 {
<a name="l00045"></a>00045         <span class="keywordflow">return</span> a1;
<a name="l00046"></a>00046 }
<a name="l00047"></a>00047 
<a name="l00048"></a><a class="code" href="class_i_r_sensors.html#a43b4167484facf9a3d7783a6eebf3481">00048</a> <span class="keywordtype">int</span> <a class="code" href="class_i_r_sensors.html#a43b4167484facf9a3d7783a6eebf3481">IRSensors::getA2</a>(<span class="keywordtype">void</span>)
<a name="l00049"></a>00049 {
<a name="l00050"></a>00050         <span class="keywordflow">return</span> a2;
<a name="l00051"></a>00051 }
<a name="l00052"></a>00052 
<a name="l00053"></a><a class="code" href="class_i_r_sensors.html#aeaeeb1140579df8a3b7cc3545f6ab0f5">00053</a> <span class="keywordtype">int</span> <a class="code" href="class_i_r_sensors.html#aeaeeb1140579df8a3b7cc3545f6ab0f5">IRSensors::getA3</a>(<span class="keywordtype">void</span>)
<a name="l00054"></a>00054 {
<a name="l00055"></a>00055         <span class="keywordflow">return</span> a3;
<a name="l00056"></a>00056 }
<a name="l00057"></a>00057 
<a name="l00058"></a><a class="code" href="class_i_r_sensors.html#a81119e8306c0607d186921ff81df90a9">00058</a> <span class="keywordtype">int</span> <a class="code" href="class_i_r_sensors.html#a81119e8306c0607d186921ff81df90a9">IRSensors::getA4</a>(<span class="keywordtype">void</span>)
<a name="l00059"></a>00059 {
<a name="l00060"></a>00060         <span class="keywordflow">return</span> a4;
<a name="l00061"></a>00061 }
<a name="l00062"></a>00062 
<a name="l00063"></a><a class="code" href="class_i_r_sensors.html#ac6f3825428d7a5615e967f13310bc25d">00063</a> <span class="keywordtype">bool</span> <a class="code" href="class_i_r_sensors.html#ac6f3825428d7a5615e967f13310bc25d">IRSensors::AFlag</a>(<span class="keywordtype">void</span>)
<a name="l00064"></a>00064 {
<a name="l00065"></a>00065         <span class="keywordflow">return</span> a;
<a name="l00066"></a>00066 }
<a name="l00067"></a>00067 
<a name="l00068"></a><a class="code" href="class_i_r_sensors.html#a71d43a2da760b6a636d6fc478f3c484c">00068</a> <span class="keywordtype">void</span> <a class="code" href="class_i_r_sensors.html#a71d43a2da760b6a636d6fc478f3c484c">IRSensors::main</a> (<span class="keywordtype">void</span>)
<a name="l00069"></a>00069 {
<a name="l00070"></a>00070         s1=35;  <span class="comment">//binnenkomende spanning van I²C</span>
<a name="l00071"></a>00071         s2=40;
<a name="l00072"></a>00072         s3=0;
<a name="l00073"></a>00073         s4=0;
<a name="l00074"></a>00074         s5=0;
<a name="l00075"></a>00075         s6=15;
<a name="l00076"></a>00076         x1= <a class="code" href="class_i_r_sensors.html#af8dc3132cb03a6816e29ac5ee58f6e60">afstand</a> (s1);
<a name="l00077"></a>00077         x2= <a class="code" href="class_i_r_sensors.html#af8dc3132cb03a6816e29ac5ee58f6e60">afstand</a> (s2);
<a name="l00078"></a>00078         x3= <a class="code" href="class_i_r_sensors.html#af8dc3132cb03a6816e29ac5ee58f6e60">afstand</a> (s3);
<a name="l00079"></a>00079         x4= <a class="code" href="class_i_r_sensors.html#af8dc3132cb03a6816e29ac5ee58f6e60">afstand</a> (s4);
<a name="l00080"></a>00080         x5= <a class="code" href="class_i_r_sensors.html#af8dc3132cb03a6816e29ac5ee58f6e60">afstand</a> (s5);
<a name="l00081"></a>00081         x6= <a class="code" href="class_i_r_sensors.html#af8dc3132cb03a6816e29ac5ee58f6e60">afstand</a> (s6);
<a name="l00082"></a>00082                 
<a name="l00083"></a>00083                 <span class="keywordflow">if</span> (x3+x4+x5+x6==0){
<a name="l00084"></a>00084                         a = <span class="keyword">false</span>;
<a name="l00085"></a>00085                 }
<a name="l00086"></a>00086                 <span class="keywordflow">else</span> {a=<span class="keyword">true</span>;}
<a name="l00087"></a>00087                 
<a name="l00088"></a>00088 
<a name="l00089"></a>00089                 <span class="keywordflow">if</span> (x1+x2==0){
<a name="l00090"></a>00090                         b = <span class="keyword">false</span>;
<a name="l00091"></a>00091                 }
<a name="l00092"></a>00092                 <span class="keywordflow">else</span> {b=<span class="keyword">true</span>;}
<a name="l00093"></a>00093 
<a name="l00094"></a>00094 
<a name="l00095"></a>00095                 <span class="keywordflow">if</span> (b)
<a name="l00096"></a>00096                 {
<a name="l00097"></a>00097                         <span class="keywordflow">if</span>(x1 + x2 &lt;= <a class="code" href="infrarood_8h.html#ac2d6ff04bfd7a68ae0ea3d3c6e5da9cd">Xnul</a>){
<a name="l00098"></a>00098                                 bx = 0;
<a name="l00099"></a>00099                                 by = 0;
<a name="l00100"></a>00100                         }
<a name="l00101"></a>00101                         <span class="keywordflow">else</span>{                   
<a name="l00102"></a>00102                                 <span class="comment">//Xnul is DEFINEd in infrarood.h                        </span>
<a name="l00103"></a>00103                                 bx = (<a class="code" href="infrarood_8h.html#ac2d6ff04bfd7a68ae0ea3d3c6e5da9cd">Xnul</a>*<a class="code" href="infrarood_8h.html#ac2d6ff04bfd7a68ae0ea3d3c6e5da9cd">Xnul</a> + x1*x1 - x2*x2)/(2*<a class="code" href="infrarood_8h.html#ac2d6ff04bfd7a68ae0ea3d3c6e5da9cd">Xnul</a>);
<a name="l00104"></a>00104                                 by = sqrt( x1*x1 - bx*bx);
<a name="l00105"></a>00105                         }
<a name="l00106"></a>00106                 }
<a name="l00107"></a>00107                 <span class="keywordflow">else</span> 
<a name="l00108"></a>00108                 {
<a name="l00109"></a>00109                         bx=0; by=0;
<a name="l00110"></a>00110                 }
<a name="l00111"></a>00111                 <span class="comment">//printf(&quot;IRSensor bx=%d by=%d \n&quot;,bx,by);</span>
<a name="l00112"></a>00112 }
<a name="l00113"></a>00113 
<a name="l00114"></a><a class="code" href="class_i_r_sensors.html#af8dc3132cb03a6816e29ac5ee58f6e60">00114</a> <span class="keywordtype">int</span> <a class="code" href="class_i_r_sensors.html#af8dc3132cb03a6816e29ac5ee58f6e60">IRSensors::afstand</a> (<span class="keywordtype">int</span> s)
<a name="l00115"></a>00115 {
<a name="l00116"></a>00116         <span class="keywordflow">return</span> s*2; <span class="comment">//tijdelijke factor, moet nog bepaald worden</span>
<a name="l00117"></a>00117 }
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Gegenereerd op Do 19 Mei 2011 10:15:28 voor Robocup-denayer-project-a door&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>
